package FunctionalClass;

import java.nio.ByteBuffer;

public class Buffer_Bit_Operation {
	public void bitSet(ByteBuffer buf, int bm_start, int b) {
		buf.position(bm_start+b/8);
		byte bit = buf.get();
		bit |= 1<<(b%8);
		buf.position(bm_start+b/8);
		buf.put(bit);
	}
	
	public void bitUnSet(ByteBuffer buf, int bm_start, int b) {
		buf.position(bm_start+b/8);
		byte bit = buf.get();
		bit &= ~(1<<(b%8));
		buf.position(bm_start+b/8);
		buf.put(bit);
	}

	public boolean bitTest(ByteBuffer buf, int bm_start, int b) {
		buf.position(bm_start+b/8);
		return ( ( buf.get() & (1<<(b%8)) ) > 0 );
	}
}
